//
//  BONCViewController.m
//  TestMe
//
//  Created by HePing on 14-9-25.
//  Copyright (c) 2014年 HePing. All rights reserved.
//

#import "BONCViewController.h"

@interface BONCViewController ()

@end

@implementation BONCViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor=[UIColor redColor];
    UIButton* myBtn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
    [myBtn setTitle:@"click me" forState:UIControlStateNormal];
    [myBtn addTarget:self action:@selector(presentVC:) forControlEvents:UIControlEventTouchUpInside];
    myBtn.frame=CGRectMake(0, 0, 60, 40);
    myBtn.center=CGPointMake(self.view.bounds.size.width/2, self.view.bounds.size.height/2);
    [self.view addSubview:myBtn];
    
    //这里是重点
    self.modalPresentationStyle=UIModalPresentationCurrentContext;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)presentVC:(id)sender
{
    
    BONCPresentViewController* preVC=[[BONCPresentViewController alloc]init];
    [self presentViewController:preVC animated:NO completion:nil];
    CATransition *animation = [CATransition animation];
    animation.duration = 2.0;
    animation.timingFunction =[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
    animation.type =kCATransitionMoveIn;
    animation.subtype = kCATransitionFromRight;
    [preVC.view.layer addAnimation:animation forKey:@"MoveInFromRight"];
}
@end
